import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/4/22 16:15
 * 五子棋
 * Emacs 计算器
 */
public class Day41 {
    //---------------------------------------------------------------------------

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int num = scanner.nextInt();
            Deque<String> nums = new ArrayDeque<>();
            for (int i = 0; i < num; i++) {
                String str = scanner.next();
                int num1;
                int num2;
                switch (str){
                    case "+":
                        num1 = Integer.parseInt(nums.pop());num2 = Integer.parseInt(nums.pop());
                        nums.push(String.valueOf(num2+num1));break;
                    case "-":
                        num1 = Integer.parseInt(nums.pop());
                        num2 = Integer.parseInt(nums.pop());
                        nums.push(String.valueOf(num2-num1));break;
                    case "*":
                        num1 = Integer.parseInt(nums.pop());
                        num2 = Integer.parseInt(nums.pop());
                        nums.push(String.valueOf(num2*num1));break;
                    case "/":
                        num1 = Integer.parseInt(nums.pop());
                        num2 = Integer.parseInt(nums.pop());
                        nums.push(String.valueOf(num2/num1));break;
                    default:nums.push(str);break;
                }
            }
            System.out.println(nums.pop());
        }
    }
    //---------------------------------------------------------------------------
    private static int[][] dire  = {{0,1},{0,-1},{1,0},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            char[][] map = new char[20][20];
            for (int  i = 0; i < 20; i++) {
                String str = scanner.nextLine();

                for (int j = 0; j < 20; j++) {
                    map[i][j] = str.charAt(j);
                }
            }
            if (check(map)){
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }
    }

    private static boolean check(char[][] map) {
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 20; j++) {
                if (map[i][j]=='+' || map[i][j]=='*'){
                    for (int k = 0; k < 8; k++) {
                        int count = 1;
                        int x = i+dire[k][0];
                        int y = j+dire[k][1];
                        while (x>=0 &&x<20 &&y>=0&&y<20 && map[x][y]==map[i][j]){
                            count++;
                            x = x+dire[k][0];
                            y = y+dire[k][1];
                        }
                        if (count==5){
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
}
